<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品审核</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../css/theme-chalk.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body class="hold-transition">
<div id="app">

    <div class="content-header">
        <h1>管理
            <small>商品审核</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>管理</el-breadcrumb-item>
            <el-breadcrumb-item>商品审核</el-breadcrumb-item>
        </el-breadcrumb>
    </div>

    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <!--查询表单-->
                <el-form :inline="true">
                    <el-form-item label="输入搜索">
                        <el-input v-model="searchMap.name" placeholder="商品名称" class="filter-item"></el-input>
                    </el-form-item>
                    <el-form-item label="商品分类">
                        <el-select v-model="searchMap.category3Id" clearable filterable placeholder="请选择">
                            <el-option
                                    v-for="item in category"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="商品品牌">
                        <el-select v-model="searchMap.brandId" clearable filterable placeholder="请选择">
                            <el-option
                                    v-for="item in brand"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id">
                            </el-option>
                        </el-select>
                        </el-input>
                    </el-form-item>
                    <el-button class="dalfBut" @click="fetchData()">查询</el-button>
                </el-form>
            </div>

            <el-table :data="tableData" stripe border style="width: 100%">
                <el-table-column prop="id" label="id" width="180"></el-table-column>
                <el-table-column prop="image" label="商品图片" width="180">
                    <template slot-scope="scope">
                        <img :src="scope.row.image">
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="商品名称" width="180">

                </el-table-column>
                <el-table-column prop="sn" label="货号" width="180"></el-table-column>
                <el-table-column prop="isMarketable" label="标签" width="180">
                    <template slot-scope="scope">
                        上架：{{scope.row.isMarketable==1?"是":"否"}}
                    </template>
                </el-table-column>
                <el-table-column prop="saleNum" label="销量" width="180"></el-table-column>
                <el-table-column prop="status" label="审核状态" width="180">
                    <template slot-scope="scope">
                        {{scope.row.status==1?"已审核":"未审核"}}<br>
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="180">
                    <template slot-scope="scope">
                        <el-button type="text" class="dalfBut" size="mini" @click="">查看</el-button>
                        <el-button type="text" class="dalfBut" size="mini" @click="openCheck(scope.row)">审核</el-button>
                    </template>
                </el-table-column>
            </el-table>

            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @size-change="fetchData"
                        @current-change="fetchData"
                        :current-page.sync="currentPage"
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="size"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total">
                </el-pagination>
            </div>
            <!--弹出窗口-->
            <el-dialog title="商品审核" :visible.sync="formVisible">
                <el-form :model="checkMap" class="demo-form-inline">
                    <el-form-item v-model="checkMap.spuId" label="商品名称:">
                        {{pojo.name}}
                    </el-form-item>
                    <el-form-item label="商品审核:">
                        <el-radio v-model="checkMap.status" label="1">审核通过</el-radio>
                        <el-radio v-model="checkMap.status" label="2">审核不通过</el-radio>
                    </el-form-item>
                    <el-form-item label="反馈详情:">
                        <el-input type="textarea" style="width: 400px;" v-model="checkMap.message"
                                  :autosize="{ minRows: 8, maxRows: 8}" placeholder="请输入内容"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="formVisible = false">取消</el-button>
                    <el-button type="primary" @click="check">确定</el-button>
                </div>
            </el-dialog>
        </div>
    </div>


</div>
</body>
<script src="/js/vue.js"></script>
<script src="/js/axios.js"></script>
<script src="/js/elementui.js"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                tableData: [],
                currentPage: 1,
                total: 10,
                size: 10,
                searchMap: {
                    isMarketable: "0"
                },
                pojo: {},
                formVisible: false,
                imageUrl: '',
                category: null,
                brand: null,
                checkMap: {},
            }
        },
        created() {
            this.fetchData();
        },
        methods: {
            fetchData() {
                axios.post(`/spu/findPage.do?page=${this.currentPage}&size=${this.size}`, this.searchMap).then(response => {
                    this.tableData = response.data.rows;
                    this.total = response.data.total;
                });
                axios.get("/brand/findAll.do").then(res => {
                    if (res.status == 200) {
                        this.brand = res.data.data;
                    }
                });
                axios.get("/category/findAll.do").then(res => {
                    if (res.status == 200) {
                        this.category = res.data;
                    }
                });
            },
            openCheck(row) {
                this.formVisible = true;
                this.checkMap = {};
                this.pojo = row;
                this.checkMap.id = this.pojo.id;
            },
            check() {
                this.formVisible = false;
                axios.post("/spu/audit.do", this.checkMap).then(res => {
                    if (res.status == 200) {
                        this.fetchData();
                    }
                })
            }
        }
    })
</script>
</html>
